package com.amc.controllers;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.amc.configs.Config;
import com.amc.dto.CommentView;
import com.amc.service.ICommentService;
import com.amc.utils.ResJsonUtil;

@Controller
@RequestMapping("/comment")
public class CommentController {

	private ICommentService service;

	@Resource(name = "commentService")
	public void setService(ICommentService service) {
		this.service = service;
	}

	@RequestMapping("/publish")
	@ResponseBody
	public Object publicComment(CommentView commentView) {
		boolean result = service.uploadComment(commentView);
		if(result == true) {
			return ResJsonUtil.responseObject(Config.SUCCESS, "", "");
		}
		return ResJsonUtil.responseObject(Config.ERROR, "", "Publish Comment Fail");
	}
	
	@RequestMapping("/commentlist")
	@ResponseBody
	public Object commentList(String merchantId) {
		List<CommentView> list = service.showComment(merchantId);
		return list;
	}
}
